package com.sybil.ot.dominio;

import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.OneToMany;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Entity
@Table(name = "SIL_USUARIOS_PERFIL")
public class Usuario implements Serializable {

   private static final long serialVersionUID = 1L;
   private String clave;
   private String nombre;
   private String password;
   private String email;
   private String activo;
   private List<Perfil> perfiles;

   public Usuario() {
   }

   public Usuario(String clave) {
      this.clave = clave;
   }

   public Usuario(String clave, String nombre, String password, String email) {
      this.clave = clave;
      this.nombre = nombre;
      this.password = password;
      this.email = email;
   }

   @Id
   @Basic(optional = false)
   @NotNull
   @Size(min = 1, max = 15)
   @Column(name = "USPE_CLAVE", nullable = false, length = 15)
   public String getClave() {
      return clave;
   }

   public void setClave(String clave) {
      this.clave = clave;
   }

   @Basic(optional = false)
   @NotNull
   @Size(min = 1, max = 100)
   @Column(name = "USPE_NOMBRE", nullable = false, length = 100)
   public String getNombre() {
      return nombre;
   }

   public void setNombre(String nombre) {
      this.nombre = nombre;
   }

   @Column(name = "USPE_PASSWORD")
   public String getPassword() {
      return password;
   }

   public void setPassword(String password) {
      this.password = password;
   }

   @Column(name = "USPE_EMAIL")
   public String getEmail() {
      return email;
   }

   @Column(name = "USPE_ACTIVO")
   public String getActivo() {
      return activo;
   }

   public void setActivo(String activo) {
      this.activo = activo;
   }

   public void setEmail(String email) {
      this.email = email;
   }

   @OneToMany(cascade = CascadeType.ALL, mappedBy = "usuario")
   public List<Perfil> getPerfiles() {
      return perfiles;
   }

   public void setPerfiles(List<Perfil> perfiles) {
      this.perfiles = perfiles;
   }

   @Override
   public int hashCode() {
      int hash = 0;
      hash += (clave != null ? clave.hashCode() : 0);
      return hash;
   }

   @Override
   public boolean equals(Object object) {
      if (!(object instanceof Usuario)) {
         return false;
      }
      Usuario other = (Usuario) object;
      if ((this.clave == null && other.clave != null) || (this.clave != null && !this.clave.equals(other.clave))) {
         return false;
      }
      return true;
   }

   @Override
   public String toString() {
      return "Usuario[ clave=" + clave + " ]";
   }
}
